﻿$(document).ready(function() {

    $("#btnCreateUrl").click(function() {

        var mimeType = $('#txtType').val();
        var forceDownload = $('#txtForceDownload').is(':checked');
        var filter = $('#txtFilter').val();
        var forceInternal = $('#txtForceDownloadOnContent').is(':checked');

        var url = window.location.toString();
        var pageName = "proxy.aspx";
        var pageIndex = url.indexOf(pageName) + pageName.length;
        url = url.substr(0, pageIndex);
        var url = url + "?url=" + $("#txtUrl").val();

        if (mimeType) {
            url = url + "&t=" + mimeType;
        }
        if (forceDownload) {
            url = url + "&f=1";
        }
        if (filter) {
            url = url + "&e=" + filter;
        }
        if (forceInternal) {
            url = url + "&fi=" + forceInternal;
        }

        $("#txtOutput").val(url);
        $("#linkOutput").html(url);
        $("#linkOutput").attr("href", url);
    });

    $("input[type='text']").click(function() {
        $(this).select();
    });
});